<!DOCTYPE html>
<html>
    <head>
		<meta charset="utf-8"/>
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    	<title>修改账号和密码</title>
    	<meta name="keywords" content="管理员" />
    	<meta name="description" content="管理员" />
		<meta name = "format-detection" content = "telephone=no">
    	<link rel="stylesheet" href="" type="text/css" />
		<link rel="shortcut icon" href="favicon.ico" /> 
		<?php
			session_start();
			error_reporting(0);
			require('inc/func.php');
			require('inc/mysql.php');
			if($_GET['out']==true){
				session_destroy();
				redirect('','redirect','login/index.php');
				exit();
			}
				if(empty($_SESSION['loginUserName'])){redirect('','redirect','login/index.php');}
			$admin_first=$db->query_first('select * from adminUser where username=\''.$_SESSION['loginUserName'].'\' and password=\''.$_SESSION['loginPassword'].'\' limit 1');
			if($db->num_rows()<0){redirect('非法访问请登录！','redirect','login/index.php');exit();}
			$adminUser=$db->query_first('select * from adminUser where id=1 limit 1');
		    $adminUsername=$adminUser['username'];
		    if($_GET['action']=='save'){
				$username=$_POST['username'];
				$password=$_POST['password'];
				$username=!empty($username)?$username:die("alert('用户名不能为空);window.location.href='editAdmin.php'");
				$password=!empty($password)?md5($password):die("alert('密码不能为空);window.location.href='editAdmin.php'");
				$db->query('select * from adminUser where username=\''.$username.'\' and id!=1 limit 1');
				if($db->num_rows()>0){redirect('该用户名已存在','redirect','editAdmin.php');exit;}
				$db->query('update adminUser set username=\''.$username.'\',password=\''.$password.'\',addtime='.time().' where id=1');
				if($db->num_affected_rows()>0){session_destroy();redirect('更新成功','redirect','login/index.php');}else{redirect('未知错误，请重试','redirect','editAdmin.php');}
			}
		?>
		<style type="text/css">
			.formDiv .txtInput {width:55%;font-size:16px;height:20px;padding:10px 10px;border:1px solid #e4e4e4;}
			.submitBtn{display:block;width:50%;height:40px;line-height:40px;border-radius:3px;margin:0 auto;background:#189ad8;color:#fff;font-size:16px;cursor:pointer;}
			.formDiv .add{font-size:14px;}

				.file {
					font-size:14px;
					color:#189ad8;
				}
				.file input {
					position: absolute;
					right: 0;
					top: 0;
					opacity: 0;
				}
				.file:hover {
					background: #AADFFD;
					border-color: #78C3F3;
					color: #004974;
					text-decoration: none;
				}
			#feedback img,#feedback2 img{
				border: 1px solid silver;
				border-radius:3px;
				padding: 3px; 
				width: 80px;height:80px;
			}
			#feedback,#feedback2{position:relative;margin-top:15px;text-align:center;background:#fff;}
			#feedback .imgClose,#feedback2 .imgClose{width:20px;height:20px;position:absolute;right:-15px;top:-10px;cursor:pointer;padding:0px;border:0px;border-radius:0px;}
			#feedback .appendP,#feedback2 .appendP{width:80px;height:65px;position:relative;float:left;margin-left:25px;margin-top:25px;margin-bottom:20px;}
			.houseAdmin .right{width:100%;}
			.houseAdmin .right .top{height:55px;}
			.houseAdmin .right .top .caidan{margin-top:10px;float:left;width:32px;height:32px;margin-left:20px;cursor:pointer;}
			.houseAdmin .right .top .input{border:0px;width:160px;float:left;height:30px;}
			.houseAdmin .right .top .touxiang{width:32px;height:32px;float:right;margin-top:10px;margin-right:10px;}
			.houseAdmin .right .top .touxiang img{max-width:100%;}
			.houseAdmin .right .top .xiala{width:12px;height:12px;float:right;margin-right:10px;margin-top:25px;cursor:pointer;position:relative;}
			.houseAdmin .right .top .xiala .xialaContent{width:110px;text-align:right;border:1px solid #ccc;position:absolute;top:-25px;right:-10px;padding-top:55px;display:none;padding-bottom:1px;}
			.houseAdmin .right .top .xiala .xialaContent a{font-size:12px;display:inline-block;width:100%;height:25px;line-height:25px;background:#3bbfb4;color:#fff;text-decoration:none;text-align:center;border-bottom:1px solid #fff;}
			.houseAdmin .right .top .xiala img{max-width:100%;}
			.houseAdmin .right .top .text{float:right;display:inline-block;margin-top:25px;margin-right:10px;}
		</style>
    </head>
    <body>
		<div class="houseAdmin" id="houseAdmin">
			<div class="right">
				<div class="top">
					<div class="caidan"><a href=""><img src="inc/images/caidan.png" alt=""/></a></div>
					
					<div class="xiala">
						<img src="inc/images/xiala.png" alt=""/>
						<div class="xialaContent">
							<a href="?out=true">loginOut</a>
							<?php if($_SESSION['loginUserName']==$adminUsername){?>
								<a href="index.php">添加商品</a>
							<?php } ?>
						</div>
					</div>
					<span class="text"><?php echo $_SESSION['loginUserName'];?></span>
					<div class="touxiang">
						<img src="inc/images/touxiang.png" alt=""/>
					</div>
				</div>	
			</div>
		</div>
		<form action="?adminName=<?php echo $_SESSION['loginUserName'];?>&action=save" method="post"> 
			<div class="formDiv">
				<p class="mb15"><span style="display:inline-block;width:30%;padding-left:15px;">用户名：</span><input type="text" name="username" id="house_areaLocation" class="txtInput" value="<?php  echo $houseArr['areaLocation'];?>" /></p>
				<p class="mb15"><span style="display:inline-block;width:30%;padding-left:15px;">密码：</span><input type="text" name="password" id="house_areaLocation" class="txtInput" value="<?php  echo $houseArr['areaLocation'];?>" /></p>
			</div>
			<div style="clear:both;"></div>
			<p class="pCenter mt15"><input type="submit" value="确认修改" class="submitBtn" /></p>
		</form>
		<div style="height:20px;clear:both;overflow:hidden;"></div>
		<script type="text/javascript" src="inc/jquery-1.7.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				$('#houseAdmin').find('.xiala').click(function(){
					$(this).find('.xialaContent').css('display','block');
				})
			});
		</script>
	</body>
</html>